﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace EFChild
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.pageCtrl1.pageSize = 4;
        }
        MyFirstDatabaseEntities1 db=new MyFirstDatabaseEntities1();

        public void LoadData()
        {
            List<Class122> list = db.Class122s.Where(d => d.成绩 > 50).ToList();
            this.pageCtrl1.SetPageCtrl(4,pageCtrl1.pageSize,list.Count);
            gridControl1.DataSource = list;
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            List<Class122> list = db.Class122s.Where(d => d.成绩 > 50).ToList();
            this.pageCtrl1.SetPageCtrl(4, pageCtrl1.pageSize, list.Count);
            gridControl1.DataSource = list;
        }

        private void pageCtrl1_CurrentPageChange(object sender, EventArgs e)
        {
            LoadData();
        }
        private void UpdateLabel()
        {
            //labelControl1.Text = string.Format("Page {0} of {1}", xpPageSelector1.CurrentPage, xpPageSelector1.PageCount);
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            //if (xpPageSelector1.CurrentPage == 0) return;
            //xpPageSelector1.CurrentPage--;
            //UpdateLabel();
        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {
            //if(xpPageSelector1.CurrentPage==xpPageSelector1.PageCount-1)
            //    return;
            //xpPageSelector1.CurrentPage++;
            //UpdateLabel();
        }

        private void gridView1_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
        {
            if (e.Info.IsRowIndicator && e.RowHandle >= 0)
            {
                e.Info.DisplayText = (e.RowHandle + 1).ToString();
            }
        }       
    }
}
